<div>
    <ul class="breadcrumb">
        <li>
            <a href="<?php echo site_url('m-admin/home')?>">管理首页</a> <span class="divider">/</span>
        </li>
        <li>
            <a href="javascript:void(0);" onclick="change_channel('contents');">内容管理</a> <span class="divider">/</span>
        </li>
        <li>
            <a href="<?php echo site_url('m-admin/order');?>">订单管理</a> <span class="divider">/</span>
        </li>

        <li>
            网站账目流水列表
        </li>
    </ul>
</div>

<div class="row-fluid">
	<div class="box">
			<div class="box-header well" data-original-title="">
				<h3>查询</h3>
				<div class="box-icon">
					<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
				</div>
			</div>
		
			<div class="box-content" style="display: block;">
                <form action="<?php echo site_url('m-admin/order/serial')?>" >
                    订单号:
                    <input type="text" name="order_id" class="input-small" />
                    支付流水:
                    <input type="text" name="serial_number" class="input-small" />
                    <button id="save_form_btn" type="submit" class="btn btn-primary">查询</button>
                </form>
        </div>     																																										       
	</div>
    <!--列表-->

    <div class="row-fluid hidden">
        <span class="span6">
        </span>
        <span class="span6">
            <a href="<?php echo site_url('m-admin/activity/add')?>" class="btn btn-toolbar btn-info pull-right">
                <i class="icon icon-add icon-white"></i>
                添加活动
            </a>
        </span>
    </div>

    <table class="table table-striped table-bordered">
        <thead>
        <tr>
            <th>订单号</th>
            <th>支付方式</th>
            <th>流水号</th>
            <th>流水生成时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="data_body">
        <?php if($pagination['list']): foreach($pagination['list'] as $vo):?>
            <tr id="data<?php echo $vo['id'];?>">
                <td><?php echo $vo['order_id'];?></td>
                <td>

                    <?php
                        echo $vo['func'];
                    ?>

                </td>
                <td>
                    <?php
                        echo $vo['serial_number'];
                    ?>

                </td>
                <td>
                    <?php
                        echo $vo['created'];
                    ?>

                </td>

                <td id="data<?php echo $vo['id'];?>">
                    <?php if($vo['status']==1): ?>
                    <a class="btn btn-success btn-mini"
                       href="javascript:void(0);">
                            <i class="icon-share icon-white"></i>
                        已支付
                    </a>
                    <?php elseif($vo['status']==2): ?>
                    <a class="btn btn-warning btn-mini"
                       href="javascript:void(0);">
                        <i class="icon-share icon-white"></i>
                        申请退款中
                    </a>
                    <?php elseif($vo['status']==0):  ?>
                        <a class="btn btn-warning btn-mini"
                           href="javascript:void(0);">
                            <i class="icon-share icon-white"></i>
                            已拒绝
                        </a>
                    <?php else: ?>
                        <a class="btn btn-info btn-mini"
                           href="javascript:void(0);">
                            <i class="icon-share icon-white"></i>
                            已退款
                        </a>
                    <?php endif; ?>
                </td>
                <td>

                <?php if($vo['status']==1): ?>
                    <a class="btn btn-warning btn-mini"
                       href="javascript:do_refund_stop(<?php echo $vo['id'];?>);">
                        <i class="icon-stop icon-white"></i>
                        拒绝申请
                    </a>
                <?php elseif($vo['status']==2): ?>
                    <a class="btn btn-warning btn-mini"
                       href="javascript:do_refund(<?php echo $vo['id'];?>,'<?php echo $vo["order_id"];?>');">
                        <i class="icon-play icon-white"></i>
                        受理退款
                    </a>
                <?php endif; ?>
                </td>
            </tr>
        <?php endforeach;endif;?>
        </tbody>
    </table>

    <div class="row-fluid pagination pagination-centered">
        <?php echo $pagination['page_html'];?>
    </div>
    <!--/列表-->
</div>


<script  type="text/javascript">
    function do_refund_stop(id)
    {
        if(!confirm('确定要拒绝当前退款申请？'))
            return false;
        $.post(
            "<?php echo site_url('m-admin/order/do_refund_stop/')?>",
            { serial_id: id},
            function(response){
                if(response.status) {
                    $(this).fadeOut();
                }else if(!response.status){
                    alert(response.msg);
                }else {
                    alert('操作失败，请重试或联系管理员！');
                    console.log(response);
                }
            },
            'json');
        return false;
    }

    function do_refund(id,oid)
    {
        if(!confirm('确定要退款？'))
            return false;
        $.post(
            "<?php echo site_url('m-admin/order/do_refund')?>",
            { serial_id: id ,order_id:oid},
            function(response){
                if(response.status) {
                    $(this).fadeOut();
                    $('data'+id).html('');
                    $('data'+id).html('<a class="btn btn-info btn-mini"href="javascript:void(0);"> <i class="icon-share icon-white"></i> 已退款 </a>');
                }else if(!response.status){
                    alert(response.msg);
                }else {
                    alert('操作失败，请重试或联系管理员！');
                    console.log(response);
                }
            },
            'json');
        return false;
    }


</script>